<template>
  <div class="dashboard">
    <div class="left-info">
      <div class="info-item" style="padding-left: 10px">
        <SvgIcon icon-class="ysingal" class="icon" />
        <div class="info">
          <span class="info-value">{{ ((getInfo?.flytime || 0) / 60).toFixed(2) }}</span>
          <span class="info-name">飞行时间(分钟)</span>
        </div>
      </div>
      <div class="info-item">
        <SvgIcon icon-class="tsingal" class="icon" />
        <div class="info">
          <span class="info-value">{{ getInfo?.mileage || '0' }}</span>
          <span class="info-name">飞行距离(米)</span>
        </div>
      </div>
      <div class="info-item" style="padding-left: 10px">
        <SvgIcon icon-class="voltage_drone" class="icon" />
        <div class="info">
          <span class="info-value">{{ getInfo?.voltage || '0' }}</span>
          <span class="info-name">电池电压</span>
        </div>
      </div>
    </div>
    <div class="right-info">
      <div class="info-item" style="padding-right: 10px">
        <SvgIcon icon-class="vspeed" class="icon" />
        <div class="info">
          <span class="info-value">{{ getInfo?.vspeed || '0' }}</span>
          <span class="info-name">垂直速度(M/S)</span>
        </div>
      </div>
      <div class="info-item">
        <SvgIcon icon-class="satcount" class="icon" />
        <div class="info">
          <span class="info-value">{{ getInfo?.satcount || '0' }}</span>
          <span class="info-name">GPS信号(星级)</span>
        </div>
      </div>
      <div class="info-item" style="padding-right: 10px">
        <SvgIcon icon-class="licheng" class="icon" />
        <div class="info">
          <span class="info-value">{{ getInfo?.distToHome || '0' }}</span>
          <span class="info-name">距机场距离(米)</span>
        </div>
      </div>
    </div>
    <div class="number-dial-container">
      <NumberDial
        :direction="-1"
        :step="0.2"
        class="speed-dial"
        :value="getInfo?.hspeed || 0"
        title="水平速度(M/S)"
      />
      <NumberDial
        :direction="1"
        :step="1"
        :value="getInfo?.alt || 0"
        class="height-dial"
        title="飞行高度(M)"
      />
    </div>
    <div class="attitude-indicator-container">
      <AttitudeIndicator :yaw="getInfo?.yaw" :pitch="getInfo?.pitch" :roll="getInfo?.roll" />
    </div>
  </div>
</template>

<script>
import SvgIcon from '@/components/SvgIcon/index.vue'
import NumberDial from '@/components/numberDial/index.tsx'
import AttitudeIndicator from '@/components/attitudeIndicator/index'
import { ref, reactive, toRefs, watch, inject, computed, unref } from 'vue'
export default {
  components: { SvgIcon, NumberDial, AttitudeIndicator },
  props: {},
  setup(props, { emit }) {
    const panelInfo = ref(inject('panelInfo'))
    const getInfo = ref(null)

    watch(panelInfo.value, (val) => {
      getInfo.value = val
      console.log('getInfo', val)
    })
    return {
      panelInfo,
      getInfo
    }
  }
}
</script>

<style lang="less" scoped>
.dashboard {
  flex-shrink: 1;
  width: 630px;
  // width: 33%;
  height: 200px;
  position: relative;
  background-image: url('@/assets/back/panel.png');
  background-size: 100% 100%;
  overflow: hidden;
  .info-item {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    .icon {
      height: 18px;
      width: 18px;
    }
    .info {
      display: flex;
      flex-direction: column;
      .info-name {
        color: #8ea8d5;
        font-size: 12px;
      }
      .info-value {
        color: #3a6fbc;
        font-size: 12px;
      }
    }
  }
  .left-info,
  .right-info {
    height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
  }
  .left-info {
    left: 20px;
    .info-item {
      flex-direction: row;
      .info {
        margin-left: 10px;
      }
    }
  }
  .right-info {
    right: 20px;
    .info-item {
      flex-direction: row-reverse;
      .info {
        align-items: flex-end;
        margin-right: 10px;
      }
    }
  }
  .number-dial-container {
    width: 400px;
    height: 400px;
    position: relative;
    top: 40%;
    left: 47%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: space-between;
    transform-origin: center center;
    scale: 0.9;
  }
  .attitude-indicator-container {
    height: 200px;
    width: 200px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
@media screen and (max-width: 1024px) {
  .dashboard{
    width: 605px;

  }
  
}
</style>
